﻿<%@ page language="java" import="java.util.*"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%
String path = request.getContextPath();
String app_version = net.zoneland.greenleaf.GLOBAL.APP_VERSION;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>		
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=10;IE=9;IE=8;" />	
  		<!-- Title and other stuffs -->
  		<title>后台管理系统</title> 
  		<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  		<script src="<%=path %>/js/greenleaf/jquery-1.8.3.js"></script> <!-- jQuery -->		
  		<script type="text/javascript">
	  		var path = "<%=path %>";
	  		var id = "${id}";
	  		var app_version = "<%=app_version %>";  		
	  		
  		</script>
 </head>
 <body>
<div id="mainbar" class="mainbar">
 <!-- Page heading -->
	<div class="page-head">
	    <h2 class="pull-left"><i class="icon-home"></i> 任务信息详情</h2>
        <!-- Breadcrumb -->
        <div class="bread-crumb pull-right">
          <a href="javascript:void()"><i class="icon-home"></i> 系统配置管理</a> 
          <!-- Divider -->
          <span class="divider">/</span> 
          <a href="javascript:void()" class="bread-current">任务信息详情</a>
        </div>
        <div class="clearfix"></div>
	</div>
	<!-- Page heading ends -->

	<!-- Matter -->
	<div class="matter">
        <div class="container">
        <!-- 页面的内容开始. -->
        <div class="row">
            <div class="col-md-12">
              <div class="widget wgreen">
                <div class="widget-content">
                   <div class="padd">
                    <h6>系统配置详情</h6>
                    <hr />
                    <!-- Form starts.  -->
                     <form class="form-horizontal" role="form">
                     	  <input id="id" type="hidden" value="0"/>
                          <div class="form-group">
                               <label class="col-lg-3 control-label">配置编码</label>
                               <div class="col-lg-3">
                                   <input id="c_code" type="text" class="form-control" placeholder="请填写配置编码">
                               </div>
                          </div>
                          <div class="form-group">
                               <label class="col-lg-3 control-label">配置内容</label>
                               <div class="col-lg-3">
                                   <input id="c_value" type="text" class="form-control" placeholder="请填写配置内容">
                               </div>
                          </div>
                          <div class="form-group">
                               <label class="col-lg-3 control-label">排序号</label>
                               <div class="col-lg-3">
                                    <select id="c_order" class="form-control">
                                      <%for(int i=1;i<=20;i++){ %>
                                    	 <option value="<%=i %>"><%=i %></option>
                                      <% }%>
                                    </select>
                                  </div>
                          </div>
                          <div class="form-group">
                                  <label class="col-lg-4 control-label">备注信息</label>
                                  <div class="col-lg-8">
                                    <textarea id="remark" class="form-control" rows="3" placeholder="请填写备注信息"></textarea>
                                  </div>
                          </div>              
                          <hr />
                          <div class="form-group">
                                  <div class="col-lg-offset-1 col-lg-9">
                                    <button name="btn_sys_config_save" type="button" class="btn btn-primary">保存信息</button>
                                    <button name="btn_sys_config_reset" type="button" class="btn btn-primary">重置信息</button>
                                    <button name="btn_sys_config_delete" type="button" class="btn btn-danger" disabled="true">删除信息</button>
                                  </div>
                           </div>
                       </form>
                  </div>
                </div>
                <div class="widget-foot"></div>
              </div>
            </div>
          </div>
        <!-- 页面的内容结束. -->
        </div>
	</div>
	<!-- Matter ends -->
</div>
<!-- jQuery Flot -->
<script src="<%=path %>/js/greenleaf/actions/sys_config_action.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	view_sys_config_info("first");
	
	$("[name='btn_sys_config_save']").click(function(){
		save_sys_config_info();
	});
	
	$("[name='btn_sys_config_reset']").click(function(){
		$("form")[0].reset();
	});
	
	$("[name='btn_sys_config_delete']").click(function(){
		delete_sys_config_info();
	});
	
});
	
function view_sys_config_info(fn){
	if(id == "null" ||id == null || id == undefined || id == "0"){
		return false;
	}
	//说明是查询
	$("#id").val(id);
	$("[name='btn_sys_config_delete']").attr("disabled", false);
	var url = sys_config_info_action.service.get;
	var paramMap = {};
	paramMap.id = id;
	var json_data = JSON.stringify(paramMap);
	$.getJSON(url, {"jsonstring":json_data}, function(json){
		//向页面上加载信息
		if(json && json.list && json.list.length > 0){
			var t_info = json.list[0];
			$("#id").val(t_info.id);
			$("#c_code").val(t_info.c_code );
	 		$("#c_value").val(t_info.c_value);
	 		$("#c_order").val(t_info.c_order);
	 		$("#remark").val(t_info.remark);
		}			
	});
}

function save_sys_config_info(){
	var sys_config_info = {};
	sys_config_info.id = $("#id").val();
	sys_config_info.c_code = $("#c_code").val();
	sys_config_info.c_value = $("#c_value").val();
	sys_config_info.c_order = $("#c_order").val();
	sys_config_info.remark = $("#remark").val();
	var json_data = JSON.stringify(sys_config_info);
	var url = sys_config_info_action.service.save;
	$.ajax({
		  url: url,
		  type : 'post',
		  async : false,
		  data: json_data,
		  contentType: "application/json; charset=utf-8",
		  dataType: "json",
		  success: function(json) {
			 alert(json.message);
			loadPage(sys_config_info_action.page.list);
			if(fn){fn();}
		  }
	});
}

function delete_sys_config_info(){
	var id = $("#id").val();
	var url = sys_config_info_action.service.remove;
	if(confirm("您确定需要删除系统配置吗？数据删除后将无法恢复。")){
		if(id!=null && id!="0" && id.length>0){
	        if(id!="" && id.length>0){        	
		        $.getJSON(url, {"id":id}, function(json){
					alert(json.message);
					loadPage(sys_config_info_action.page.list);
				});
	        }      
		}
	}
}

</script>
</body>